package com.test.vote.service;

import com.test.vote.mapper.BattleDao;
import com.test.vote.mapper.VoteDao;
import com.test.vote.pojo.Battle;
import com.test.vote.pojo.Match;
import com.test.vote.pojo.Vote;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class voteService {
    @Resource
    VoteDao voteDao;
    @Resource
    BattleDao battleDao;

    //判断是否投过票
    public Vote ifVote(Vote vote) {
        return voteDao.ifVote(vote);
    }

    //添加投票
    public int vote(Vote vote) {
        return voteDao.insert(vote);
    }

    //对战表加投票量
    public int addAVote(int battleId) {
        return battleDao.updateATicket(battleId);
    }

    //对战表加投票量
    public int addBVote(int battleId) {
        return battleDao.updateBTicket(battleId);
    }

    //通过比赛Id找到排名信息
    public List<Map<String, Integer>> selctTop(Match match) {
        return voteDao.selctTop(match);
    }
}
